package com.fr.web.platform;

import com.fr.base.FRContext;
import com.fr.privilege.authentication.Authentication;
import com.fr.privilege.authority.Authority;

public class PlatformPermissionAndAuthorityControl extends PlatformControl
{
  public boolean access(Authentication paramAuthentication)
  {
    if (paramAuthentication == null)
      return false;
    Authority[] arrayOfAuthority = paramAuthentication.getAuthorities();
    if ((arrayOfAuthority == null) || (arrayOfAuthority.length == 0))
      return false;
    PlatformManager localPlatformManager = FRContext.getPlatformManager();
    int i = 0;
    int j = arrayOfAuthority.length;
    while (i < j)
    {
      if (localPlatformManager.getPlatformControl().getAuthorityName(arrayOfAuthority[i].getName()) != null)
      {
        paramAuthentication.setAuthorities(new Authority[] { new Authority(arrayOfAuthority[i].getName()) });
        return true;
      }
      ++i;
    }
    return false;
  }

  public String getID()
  {
    return "1";
  }
}